package com.example.combwx.mvp.view.fragment;


import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.example.combwx.R;
import com.example.combwx.mvp.base.model.BaseEntity;
import com.example.combwx.mvp.base.view.BaseFragment;
import com.example.combwx.mvp.contract.RegisterContract;
import com.example.combwx.mvp.di.DaggerRegisterComponent;
import com.example.combwx.mvp.di.RegisterModels;
import com.example.combwx.mvp.model.HttpCode;
import com.example.combwx.mvp.model.entity.ResponseUserEntity;
import com.example.combwx.mvp.presenter.RegisterPresenter;
import com.example.combwx.utils.ToasetUtils;

/**
 * A simple {@link Fragment} subclass.
 */
public class PhoneFragment extends BaseFragment<RegisterPresenter> implements RegisterContract.IRegisterView, View.OnClickListener {

    private EditText account_username;
    private EditText account_pwd;
    private Button account_login_but;

    public PhoneFragment() {
        // Required empty public constructor
    }



//    @Override
//    public View addStatusView() {
//        return f(R.id.phone_linear);
//    }
//
//    @Override
//    public int addColor() {
//        return Color.WHITE;
//    }

    @Override
    public int bindLayout() {
        return R.layout.fragment_phone;
    }

    @Override
    public void initView() {
        account_username =f(R.id.account_username);
        account_pwd =f(R.id.account_pwd);
        account_login_but =f(R.id.account_login_but);
        account_login_but.setOnClickListener(this::onClick);
    }

    @Override
    public void initData() {

    }

    @Override
    public void inject() {
        DaggerRegisterComponent.builder()
                .registerModels(new RegisterModels(this))
                .build().phone(this);
    }

    @Override
    public void regirefres(BaseEntity entity) {
    }

    @Override
    public void onClick(View view) {
        String username = account_username.getText().toString();
        String pwd = account_pwd.getText().toString();
        if (TextUtils.isEmpty(username)||TextUtils.isEmpty(pwd)){
            ToasetUtils.showMsg("不能为空");
            return;
        }else {
            p.getLogin(username,pwd, HttpCode.REGISTCODE);
        }
    }
}
